/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.view.baseDataView;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;

import com.ruipengkj.commons.util.Util;
import com.ruipengkj.component.RPJButtonWhite;
import com.ruipengkj.component.jdialog.BorderJPanel;
import com.ruipengkj.component.jdialog.IDialog;
import com.ruipengkj.component.jtree.OverwriteDefaultMutableTreeNode;
/**
 * 说明：
 * 部门分类选择页面
 * @Author：李智深
 * @Date：2012-03-14
 */
public class DataEmployeesSelectDialog extends IDialog {

	private static final long serialVersionUID = 1L;
	
	private DataTDeptTreePanel dataTDeptTreePanel; 
	private JButton noButton; //取消按钮
	private OverwriteDefaultMutableTreeNode treeNode;
	private int nodeRow;//第几行
	public DataEmployeesSelectDialog(JDialog jd, String title, boolean b) {
		super(jd, title, b);
		this.initViews();
		this.initListener();
		this.setSize(450, 500);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}
	
	
	private void initViews() {
		dataTDeptTreePanel=new DataTDeptTreePanel();
		dataTDeptTreePanel.getTree().addMouseListener(this);
		dataTDeptTreePanel.setCursor(Util.CURSOR_DEFAULT);
		JPanel jp100 = new BorderJPanel();
		noButton = new RPJButtonWhite("取消");
		jp100.add(noButton);
		this.add(dataTDeptTreePanel);
		this.add(jp100, BorderLayout.SOUTH);
		
	}
	private void initListener(){
		noButton.addActionListener(this);
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == noButton) {
			this.dispose();
		}
		super.actionPerformed(e);
	}
	@Override
	public void mouseClicked(MouseEvent e) {
		if(e.getSource()==dataTDeptTreePanel.getTree()){
			if(e.getClickCount()==2){
				treeNode = (OverwriteDefaultMutableTreeNode) dataTDeptTreePanel.getTree().getLastSelectedPathComponent();
				if(treeNode!=null){
					nodeRow=dataTDeptTreePanel.getTree().getLeadSelectionRow();
					this.dispose();
				}
			}
		}
	}

	public int getNodeRow() {
		return nodeRow;
	}


	public OverwriteDefaultMutableTreeNode getTreeNode() {
		return treeNode;
	}
	
	public static void main(String[] args) {
		new DataEmployeesSelectDialog(null, "添加员工", true);
	}
}